package mail.fetch.m21cn;

import com.han.http.client.paramter.FormDataPair;
import com.han.http.client.paramter.RequestHeader;
import com.han.http.fetch.Fetcher;

import java.util.List;
import java.util.Map;

import static com.han.http.util.Print.printMap;

@Deprecated
class Inbox {

    void getMailBrief(Map<String, String> cookieRepository) throws Exception {
        String url = "http://mail.21cn.com/w2/mail/listMail.do";
        String cookie = "JSESSIONID=" + cookieRepository.get("LSID") +
                ";LSID=" + cookieRepository.get("LSID") +
                ";apm_ct=" + cookieRepository.get("apm_ct") +
                ";apm_sid=" + cookieRepository.get("apm_sid") +
                ";apm_uid=" + cookieRepository.get("apm_uid") +
                ";apm_ip=" + cookieRepository.get("101.80.96.164") +
                ";apm_ua=" + cookieRepository.get("apm_ua") +
                ";qimo_seosource_ef9e5f30-ed02-11e6-8921-5bf6fce3cd5e=" + "%E7%AB%99%E5%86%85" +
                ";qimo_seokeywords_ef9e5f30-ed02-11e6-8921-5bf6fce3cd5e=" +
                ";href=" + "http%3A%2F%2Fmail.21cn.com%2Fw2%2F" +
                ";accessId=" + cookieRepository.get("accessId") +
                ";pageViewNum=" + "1" +
                ";bad_idef9e5f30-ed02-11e6-8921-5bf6fce3cd5e=" + cookieRepository.get("userId") +
                ";nice_idef9e5f30-ed02-11e6-8921-5bf6fce3cd5e=" + cookieRepository.get("sessionId") +
                ";BINDMOBILEFLAT=" + "BINDMOBILEFLAT" +
                ";21CNSESSION_ID=" + cookieRepository.get("21CNSESSION_ID") +
                ";21CNACCOUNT=" + cookieRepository.get("21CNACCOUNT");
        RequestHeader[] requestHeaders = {
                new RequestHeader("Host","mail.21cn.com"),
                new RequestHeader("Proxy-Connection","keep-alive"),
                new RequestHeader("Content-Length","69"),
                new RequestHeader("Accept","application/json, text/javascript, */*; q=0.01"),
                new RequestHeader("Origin","http://mail.21cn.com"),
                new RequestHeader("X-Requested-With","XMLHttpRequest"),
                new RequestHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"),
                new RequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),
                new RequestHeader("Referer","http://mail.21cn.com/w2/template/inbox.jsp"),
                new RequestHeader("Accept-Encoding","gzip, deflate"),
                new RequestHeader("Accept-Language","zh-CN,zh;q=0.9"),
                new RequestHeader("Cookie", cookie),
        };

        FormDataPair[] formDataPairs = {
                new FormDataPair("noCache","0.5784966513388365"),
                new FormDataPair("labelId","1"),
                new FormDataPair("pageNum","1"),
                new FormDataPair("sortWay","68"),
                new FormDataPair("sortField","0"),
        };

        int connectTimeout = 1000 * 3;
        int readTimeout = 1000 * 3;
        Fetcher fetcher = new Fetcher();
        Map<String, List<String>> map = fetcher.getAllInfoByPost(url, requestHeaders, formDataPairs, connectTimeout, readTimeout, true, null);
        printMap(map);
    }
}
